QT       += core gui widgets qml quick

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = MarkdownEditor
TEMPLATE = app

# C++标准设置
CONFIG += c++17
QMAKE_CXXFLAGS += -std=c++17

# 项目文件列表
SOURCES += \
    src/main.cpp \
    src/mainwindow.cpp \
    src/markdowneditor.cpp \
    src/markdownrenderer.cpp \
    src/settingsmanager.cpp \
    src/historymanager.cpp \
    src/pluginmanager.cpp \
    src/translationsmanager.cpp

HEADERS += \
    src/mainwindow.h \
    src/markdowneditor.h \
    src/markdownrenderer.h \
    src/settingsmanager.h \
    src/historymanager.h \
    src/pluginmanager.h \
    src/translationsmanager.h

FORMS += \
    forms/mainwindow.ui \
    forms/settingsdialog.ui

RESOURCES += \
    resources.qrc

# QML文件
QML_IMPORT_PATH += qml
QML_FILES += \
    qml/SettingsPage.qml \
    qml/ThemeManager.qml

# 外部库依赖
unix: LIBS += -lcommonmark -lsqlite3
win32: LIBS += -lcommonmark -lsqlite3

# 包含路径
INCLUDEPATH += \
    $$PWD/src \
    $$PWD/forms \
    $$PWD/include

DEPENDPATH += \
    $$PWD/src \
    $$PWD/forms

# 安装配置
target.path = $$[QT_INSTALL_BINS]
INSTALLS += target

# 翻译文件
TRANSLATIONS += \
    translations/markdowneditor_zh_CN.ts \
    translations/markdowneditor_en.ts

# 生成翻译文件规则
update_translations.commands = lupdate $$PWD -ts $$TRANSLATIONS
release_translations.commands = lrelease $$TRANSLATIONS
QMAKE_EXTRA_TARGETS += update_translations release_translations

# 性能优化编译选项
QMAKE_CXXFLAGS_RELEASE += -O3 -march=native
QMAKE_LFLAGS_RELEASE += -Wl,-O3

# 平台特定配置
win32 {
    # Windows特定设置
    RC_ICONS = resources/icons/app_icon.ico
    QMAKE_CXXFLAGS += -DWIN32
}

macx {
    # macOS特定设置
    ICON = resources/icons/app_icon.icns
    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14
    QMAKE_CXXFLAGS += -DMACOS
}

unix:!macx {
    # Linux特定设置
    QMAKE_CXXFLAGS += -DLINUX
    target.path = /usr/bin
    INSTALLS += target
    # 安装桌面文件
    desktop.path = /usr/share/applications
    desktop.files += resources/desktop/markdowneditor.desktop
    INSTALLS += desktop
}